package com.pocketsweet.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.pocketsweet.R;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.pocketsweet.chat.ui.activity.BaseActivity;
import com.pocketsweet.ui.uilib.SmoothImageView;

@ContentView(R.layout.dialog_datu)
public class DialogDaTu extends BaseActivity implements OnClickListener {

	@ViewInject(R.id.rlContent)
	private RelativeLayout rlContent;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ViewUtils.inject(this);
		Intent intent = getIntent();
		String url = intent.getStringExtra("url");
		int mLocationX = getIntent().getIntExtra("locationX", 0);
		int mLocationY = getIntent().getIntExtra("locationY", 0);
		int mWidth = getIntent().getIntExtra("width", 0);
		int mHeight = getIntent().getIntExtra("height", 0);

		SmoothImageView imageView = new SmoothImageView(this);
		imageView.setOriginalInfo(mWidth, mHeight, mLocationX, mLocationY);
		imageView.transformIn();
		imageView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
		imageView.setScaleType(ScaleType.FIT_CENTER);
		setContentView(imageView);
		ImageLoader.getInstance().displayImage(url, imageView);
		imageView.setOnClickListener(this);
	}


	@Override
	public void onClick(View v) {
		DialogDaTu.this.finish();		
	}

}
